﻿using Super.Admin.Utils.EventAggregator;
using Super.Admin.Utils.EventAggregator.EventType;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Super.Admin.Views.Login
{
    public partial class UcLoginContent : UserControl
    {
        public bool IsRememberPassword { get; private set; } = false;
        private string _userName;
        public string UserName
        {
            get { return _userName; }
            set
            {
                _userName = value;
                TxtUserName.Text = value;
            }
        }

        private string _password;
        public string Password
        {
            get { return _password; }
            set
            {
                _password = value;
                TxtPassword.Text = value;
            }
        }


        public UcLoginContent()
        {
            InitializeComponent();
        }

        private void BtnLogin_Click(object sender, EventArgs e)
        {
            LoginEvent loginEvent = new LoginEvent();
            loginEvent.UserName = TxtUserName.Text;
            loginEvent.Password = TxtPassword.Text;
            loginEvent.Type = LoginEvent.LoginType.Login;
            if (BtnLogin.Text == "注册")
            {
                loginEvent.Type = LoginEvent.LoginType.Register;
            }
            EventAggregator.Default.Publish<LoginEvent>(loginEvent);
        }

        private void LblRegister_Click(object sender, EventArgs e)
        {
            BtnLogin.Text = BtnLogin.Text == "注册" ? "登录" : "注册";
            LblRegister.Text = LblRegister.Text == "点击注册" ? "返回登录" : "点击注册";
        }

        private void ChkRememberPassword_CheckedChanged(object sender, AntdUI.BoolEventArgs e)
        {
            IsRememberPassword = e.Value;
        }
    }
}
